using System;
using System.Windows.Forms;

using FreeFlow.Administration;

namespace FreeFlowAdministrator
{
	/// <summary>
	/// Summary description for UserAdaptor.
	/// </summary>
	public class UserAdaptor : Adaptor, IDeletable, IRefreshable
	{
    private User user;
		public UserAdaptor(User user)
		{
      this.user = user;
		}

    public override int ImageIndex
    {
      get
      {
        return 0;
      }
    }

    public override string Text
    {
      get
      {
        return user.Name;
      }
    }

    public override Control GetRenderer()
    {
      UserControl control = new UserControl();
      control.LoadUser(user);
      control.ItemDeleted += new EventHandler(TriggerItemDeleted);
      control.RefreshRequired += new EventHandler(TriggerRefreshRequired);
      return control;
    }

    public override object Object
    {
      get
      {
        return user;
      }
    }

    #region IDeletable Members

    public void Delete()
    {
      user.Delete();
    }

    #endregion
    #region IRefreshable Members

    public void Refresh()
    {
      user.Refresh();
    }

    #endregion
  }
}
